package com.shopping.www.mapper;

import com.shopping.www.model.Brand;
import com.shopping.www.model.RegisterBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AdminMapper {

    //根据输入查询商家
    @Select("select * from db_user where username=#{username} and status=#{status} and banStatus=0")
    RegisterBean selectByInputBan(@Param("username") String username, @Param("status") String status);
    //根据商家名修改db_user表的信息
    void banBusiness1(String username);
    //根据商家名查找其id
    @Select("select id from db_user where username=#{username}")
    int selectBanBusiness(String username);
    ////根据db_user表得到的id得到商家表的user_id并作出对商家表的修改
    void banBusiness2(int user_id);
    @Select("select * from db_user where status=#{status} and banStatus=1")
    List<RegisterBean> selectBusinessBans(String status);
    void liftBanBusiness1(String username);
    void liftBanBusiness2(int user_id);
    @Select("select status from brand where id=#{id}")
    int checkBanBrand(int id);
    //根据brand_id查找apply
    @Select("select liftBanApply from busniess_msg where brand_id=#{brand_id}")
    String selectBanBrandApply(int brand_id);
    //根据商家名查找商家id
    @Select("select id from db_user where username=#{businessName}")
    int selectBusinessId(String businessName);
    //根据商家名查找其货架商品id
    @Select("select brand_id from busniess_msg where user_id=#{businessId} and shelveNum>0 ")
    int[] selectShelveIds(int businessId);
    List<Brand> selectForBan(@Param("ids") int[] ids);
    void banBrand1(int id);
    @Select("select shelveNum from busniess_msg where brand_id=#{brand_id}")
    int shelveNum(int brand_id);
    @Select("select wareNum from busniess_msg where brand_id=#{brand_id}")
    int wareNum(int brand_id);
    void banBrand2(@Param("shelveNum") int shelveNum,@Param("wareNum") int wareNum,@Param("brand_id") int brand_id);

    //查找已被封禁的商家的id
    @Select("select id from db_user where banStatus=1")
    int[] selectBan_id();
    //查找已被封禁的商家的id对应的商家表的brand_id
    int[] selectBrand_id(@Param("ids") int[] ids);
    //查找未被封禁的商家的未被封禁的商品
    List<Brand> selectBanBrands(@Param("brand_ids") int[] brand_ids);
    //解禁商品
    void liftBanBrand(Integer id);

}
